import 'package:nyh_motorcade_app/entity/driver_details_entity.dart';
import 'package:nyh_motorcade_app/entity/card_info_entity.dart';

driverDetailsEntityFromJson(DriverDetailsEntity data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'].toString();
	}
	if (json['createTime'] != null) {
		data.createTime = json['createTime'].toString();
	}
	if (json['createUser'] != null) {
		data.createUser = json['createUser'].toString();
	}
	if (json['createUserId'] != null) {
		data.createUserId = json['createUserId'].toString();
	}
	if (json['updateTime'] != null) {
		data.updateTime = json['updateTime'].toString();
	}
	if (json['updateUser'] != null) {
		data.updateUser = json['updateUser'].toString();
	}
	if (json['updateUserId'] != null) {
		data.updateUserId = json['updateUserId'].toString();
	}
	if (json['createEmpno'] != null) {
		data.createEmpno = json['createEmpno'];
	}
	if (json['updateEmpno'] != null) {
		data.updateEmpno = json['updateEmpno'];
	}
	if (json['headquarterGroupId'] != null) {
		data.headquarterGroupId = json['headquarterGroupId'] is String
				? int.tryParse(json['headquarterGroupId'])
				: json['headquarterGroupId'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['phone'] != null) {
		data.phone = json['phone'].toString();
	}
	if (json['status'] != null) {
		data.status = json['status'] is String
				? int.tryParse(json['status'])
				: json['status'].toInt();
	}
	if (json['motorcadeId'] != null) {
		data.motorcadeId = json['motorcadeId'].toString();
	}
	if (json['motorcadeName'] != null) {
		data.motorcadeName = json['motorcadeName'].toString();
	}
	if (json['subCompanyList'] != null) {
		data.subCompanyList = (json['subCompanyList'] as List).map((v) => v.toString()).toList().cast<String>();
	}
	if (json['ifCardModel'] != null) {
		data.ifCardModel = json['ifCardModel'] is String
				? int.tryParse(json['ifCardModel'])
				: json['ifCardModel'].toInt();
	}
	if (json['belongingType'] != null) {
		data.belongingType = json['belongingType'].toString();
	}
	if (json['belongingTypeName'] != null) {
		data.belongingTypeName = json['belongingTypeName'].toString();
	}
	if (json['enableEdit'] != null) {
		data.enableEdit = json['enableEdit'];
	}
	if (json['cardList'] != null) {
		data.cardList = (json['cardList'] as List).map((v) => CardInfoItem().fromJson(v)).toList();
	}
	if (json['remake'] != null) {
		data.remake = json['remake'].toString();
	}
	if (json['refuelQuota'] != null) {
		data.refuelQuota = json['refuelQuota'] is String
				? double.tryParse(json['refuelQuota'])
				: json['refuelQuota'].toDouble();
	}
	if (json['remainQuota'] != null) {
		data.remainQuota = json['remainQuota'] is String
				? double.tryParse(json['remainQuota'])
				: json['remainQuota'].toDouble();
	}
	if (json['circle'] != null) {
		data.circle = json['circle'].toString();
	}
	if (json['unit'] != null) {
		data.unit = json['unit'].toString();
	}
	if (json['circleName'] != null) {
		data.circleName = json['circleName'].toString();
	}
	if (json['unitName'] != null) {
		data.unitName = json['unitName'].toString();
	}
	return data;
}

Map<String, dynamic> driverDetailsEntityToJson(DriverDetailsEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['createTime'] = entity.createTime;
	data['createUser'] = entity.createUser;
	data['createUserId'] = entity.createUserId;
	data['updateTime'] = entity.updateTime;
	data['updateUser'] = entity.updateUser;
	data['updateUserId'] = entity.updateUserId;
	data['createEmpno'] = entity.createEmpno;
	data['updateEmpno'] = entity.updateEmpno;
	data['headquarterGroupId'] = entity.headquarterGroupId;
	data['name'] = entity.name;
	data['phone'] = entity.phone;
	data['status'] = entity.status;
	data['motorcadeId'] = entity.motorcadeId;
	data['motorcadeName'] = entity.motorcadeName;
	data['subCompanyList'] = entity.subCompanyList;
	data['ifCardModel'] = entity.ifCardModel;
	data['belongingType'] = entity.belongingType;
	data['belongingTypeName'] = entity.belongingTypeName;
	data['enableEdit'] = entity.enableEdit;
	data['cardList'] =  entity.cardList?.map((v) => v.toJson())?.toList();
	data['remake'] = entity.remake;
	data['refuelQuota'] = entity.refuelQuota;
	data['remainQuota'] = entity.remainQuota;
	data['circle'] = entity.circle;
	data['unit'] = entity.unit;
	data['circleName'] = entity.circleName;
	data['unitName'] = entity.unitName;
	return data;
}